package com.zz.tijian.expections.advice;

import com.zz.tijian.entity.res.Result;
import com.zz.tijian.expections.BadRequestException;
import com.zz.tijian.expections.ThirdPartyException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ThirdPartyExceptionAdvice {
    @ExceptionHandler({ThirdPartyException.class})
    public Result badRequestException(ThirdPartyException e) {
        log.error("请求异常，message:{},e", e.getMessage(),e);
        // TODO 标识异常已被处理
        return Result.error(e.getCode(), e.getMessage());
    }
}
